package com.tengju.support.domain.model.article;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum ArticleType {

    NOTICE(1,"公告"),
    RULE(2,"规则"),
    ACTIVITY(3,"活动"),
    COMPLIANCE_NOTICE(4,"合规公告"),
    VIOLATION_NOTICE(5,"违规公告"),
    ;

    private Integer val;
    private String desc;

    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public static ArticleType fromVal(Integer val) {
        for (ArticleType type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return null;
    }


    public static ArticleType fromName(String name) {
        for (ArticleType type : values()) {
            if (type.name().equals(name)) {
                return type;
            }
        }
        return null;
    }

}
